package cn.wch.blelib.host.gattNameResolver;

import java.util.HashMap;
import java.util.UUID;

/**
 * GATT服务
 */
public class GATT_Services {
    private static final String ZERO="0000";
    private static final String UUID_TAIL="-0000-1000-8000-00805f9b34fb";
    private static HashMap<String, GATT_uuidNmae> mServices = new HashMap<>();

    public static GATT_uuidNmae getServiceName(UUID uuid){
        return getServiceName(uuid.toString().toLowerCase());
    }
    static public GATT_uuidNmae getServiceName(final String uuid){
//        String result = mServices.get(uuid.toLowerCase());
//        if(result == null) result = "Unknown Service";
//        return result;
        GATT_uuidNmae result=null;
        if(uuid.length()==4){
            result = mServices.get(ZERO+uuid.toLowerCase()+UUID_TAIL);
        }else if(uuid.length()==8){
            result = mServices.get(uuid.toLowerCase()+UUID_TAIL);
        }else if(uuid.length()==(8+UUID_TAIL.length())){
            result = mServices.get(uuid.toLowerCase());
        }
        if(result == null) result = new GATT_uuidNmae("Unknown Service","未知服务");
        return result;
    }
    static {
        mServices.put(ZERO+"1800"+UUID_TAIL,new GATT_uuidNmae("Generic Access","通用访问"));
        mServices.put(ZERO+"1801"+UUID_TAIL,new GATT_uuidNmae("Generic Attribute","通用属性"));
        mServices.put(ZERO+"1802"+UUID_TAIL,new GATT_uuidNmae("Immediate Alert","即时闹钟"));
        mServices.put(ZERO+"1803"+UUID_TAIL,new GATT_uuidNmae( "Link Loss","连接丢失"));
        mServices.put(ZERO+"1804"+UUID_TAIL,new GATT_uuidNmae( "Tx Power","发送功率"));
        mServices.put(ZERO+"1805"+UUID_TAIL,new GATT_uuidNmae("Current Time Service","当前时间"));
        mServices.put(ZERO+"1806"+UUID_TAIL,new GATT_uuidNmae("Reference Time Update Service","参照时间更新"));
        mServices.put(ZERO+"1807"+UUID_TAIL,new GATT_uuidNmae( "Next DST Change Service","下一个DST（夏令时）更改服务"));
        mServices.put(ZERO+"1808"+UUID_TAIL,new GATT_uuidNmae("Glucose","血糖"));
        mServices.put(ZERO+"1809"+UUID_TAIL,new GATT_uuidNmae("Health Thermometer","温度计"));
        mServices.put(ZERO+"180a"+UUID_TAIL,new GATT_uuidNmae("Device Information","设备信息"));
        mServices.put(ZERO+"180d"+UUID_TAIL,new GATT_uuidNmae("Heart Rate","心率"));
        mServices.put(ZERO+"180e"+UUID_TAIL,new GATT_uuidNmae( "Phone Alert Status Service","手机报警状态"));
        mServices.put(ZERO+"180f"+UUID_TAIL,new GATT_uuidNmae("Battery Service","电池数据"));
        mServices.put(ZERO+"1810"+UUID_TAIL,new GATT_uuidNmae("Blood Pressure","血压"));
        mServices.put(ZERO+"1811"+UUID_TAIL,new GATT_uuidNmae("Alert Notification Service","闹钟通知服务"));
        mServices.put(ZERO+"1812"+UUID_TAIL,new GATT_uuidNmae("Human Interface Device","人机界面设备"));
        mServices.put(ZERO+"1813"+UUID_TAIL,new GATT_uuidNmae( "Scan Parameters","扫描参数"));
        mServices.put(ZERO+"1814"+UUID_TAIL,new GATT_uuidNmae("Running Speed and Cadence","跑步速度和节奏"));
        mServices.put(ZERO+"1815"+UUID_TAIL,new GATT_uuidNmae("Automation IO","自动化输入输出"));
        mServices.put(ZERO+"1816"+UUID_TAIL,new GATT_uuidNmae("Cycling Speed and Cadence","骑行速度和节奏"));
        mServices.put(ZERO+"1818"+UUID_TAIL,new GATT_uuidNmae( "Cycling Power","骑行能量"));
        mServices.put(ZERO+"1819"+UUID_TAIL,new GATT_uuidNmae("Location and Navigation","定位及导航"));
        mServices.put(ZERO+"181a"+UUID_TAIL,new GATT_uuidNmae( "Environmental Sensing","环境传感"));
        mServices.put(ZERO+"181b"+UUID_TAIL,new GATT_uuidNmae("Body Composition","身体组成"));
        mServices.put(ZERO+"181c"+UUID_TAIL,new GATT_uuidNmae( "User Data","用户数据"));
        mServices.put(ZERO+"181d"+UUID_TAIL,new GATT_uuidNmae( "Weight Scale","体重秤"));
        mServices.put(ZERO+"181e"+UUID_TAIL,new GATT_uuidNmae("Bond Management Service","设备绑定管理"));
        mServices.put(ZERO+"181f"+UUID_TAIL,new GATT_uuidNmae("Continuous Glucose Monitoring","动态血糖检测"));
        mServices.put(ZERO+"1820"+UUID_TAIL,new GATT_uuidNmae( "Internet Protocol Support Service","互联网协议支持"));
        mServices.put(ZERO+"1821"+UUID_TAIL,new GATT_uuidNmae( "Indoor Positioning","室内定位"));
        mServices.put(ZERO+"1822"+UUID_TAIL,new GATT_uuidNmae( "Pulse Oximeter Service","脉搏血氧计"));
        mServices.put(ZERO+"1823"+UUID_TAIL,new GATT_uuidNmae("HTTP Proxy","HTTP代理"));
        mServices.put(ZERO+"1824"+UUID_TAIL,new GATT_uuidNmae( "Transport Discovery","传输发现"));
        mServices.put(ZERO+"1825"+UUID_TAIL,new GATT_uuidNmae( "Object Transfer Service","对象传输"));
        mServices.put(ZERO+"1826"+UUID_TAIL,new GATT_uuidNmae( "Fitness Machine","健康设备"));
        mServices.put(ZERO+"1827"+UUID_TAIL,new GATT_uuidNmae( "Mesh Provisioning Service","Mesh配置服务"));
        mServices.put(ZERO+"1828"+UUID_TAIL,new GATT_uuidNmae( "Mesh Proxy Service","Mesh代理服务"));
        mServices.put(ZERO+"1829"+UUID_TAIL,new GATT_uuidNmae( "Reconnection Configuration","重连配置"));
        mServices.put(ZERO+"183a"+UUID_TAIL,new GATT_uuidNmae( "Insulin Delivery","胰岛素给药"));
        mServices.put(ZERO+"183b"+UUID_TAIL,new GATT_uuidNmae("Binary Sensor","二元传感器"));
        mServices.put(ZERO+"183c"+UUID_TAIL,new GATT_uuidNmae( "Emergency Configuration","应急配置"));
    }
}
